﻿using Microsoft.Win32;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using XYX.Print.Impl;
using XYX.Print.Models.Models;
using XYX.Print.Utils;

namespace XYX.Print.Client
{
    public partial class RegistForm : UIForm
    {
        public RegistForm()
        {
            InitializeComponent();
            this.txtRegist.ReadOnly = true;
        }

        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btnRegist_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtRegist.Text))
            {
                ShowWarningTip("请先获取注册码");
                return;
            }
            SysRegistConfigImpl impl = new SysRegistConfigImpl();
            await impl.Register(txtRegist.Text);
            UIMessageBox.Show("注册成功");
            this.Close();
        }

        /// <summary>
        /// 获取CPU
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGetCpu_Click(object sender, EventArgs e)
        {
            IdentificationClass identificationClass = Computer.GetComputerInfo();
            if (identificationClass != null)
            {
                txtRegist.Text = identificationClass.CPU;

            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
